exports.createPages = async ({ actions, graphql }) => {
  const { createPage } = actions

  const { data } = graphql(`
    query {
      allArticle {
        nodes {
          slug
        }
      }
    }
  `)

  data.allArticle.nodes.forEach(article => {
    createPage({
      path: `/article/${article.slug}`,
      component: require.resolve("../../src/templates/article"),
      context: {
        slug: article.slug,
      },
    })
  })
}
